package com.example.hilt_learn.di.module

import com.example.hilt_learn.bean.ChinaCar
import com.example.hilt_learn.bean.engine.AmericaEngine
import com.example.hilt_learn.bean.engine.ChinaEngine
import com.example.hilt_learn.bean.engine.Engine
import com.example.hilt_learn.di.anno.MadeInCN
import com.example.hilt_learn.di.anno.MadeInUSA
import dagger.Binds
import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
import dagger.hilt.android.components.ActivityComponent

@Module
@InstallIn(ActivityComponent::class)
abstract class MainModule {
    @Binds
    @MadeInCN
    abstract fun bindEngine(engine: ChinaEngine): Engine

    @Binds
    @MadeInUSA
    abstract fun bindEngine2(engine: AmericaEngine): Engine
}

@Module
@InstallIn(ActivityComponent::class)
object MainModule2 {
    @Provides
    @MadeInCN
    fun bindChinaCar(engine: ChinaEngine): ChinaCar {
        return ChinaCar(engine)
    }

    @Provides
    @MadeInUSA
    fun bindChinaCar2(engine: AmericaEngine): ChinaCar {
        return ChinaCar(engine)
    }
}
